package chapter10.exercise.test23;

public class B {
    private U[] us;
    private int index = 0;

    public B(int count) {
        us = new U[count];
    }

    public void add(U u) {
        if (index < us.length) {
            us[index++] = u;
        }
    }

    public void foreachU() {
        for (U u : us) {
            u.u1();
            u.u2();
            u.u3();
        }
    }

    public void removeU(int index) {
        if (index <= this.index) {
            us[index] = null;
        }
    }

}
